package com.example.constellation.Adapter;

import android.content.Context;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.constellation.R;
import com.example.constellation.bean.Starfg1bean;

import java.util.List;

public class fg1conadapter extends BaseAdapter {
    private Context context;

    public fg1conadapter(Context context, List<Starfg1bean> mdatas) {
        this.context = context;
        this.mdatas = mdatas;
    }

    private List<Starfg1bean> mdatas;

    @Override
    public int getCount() {
        return mdatas.size();
    }

    @Override
    public Object getItem(int position) {
        return mdatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        viewholder holder=null;
        if (convertView==null) {
            convertView= LayoutInflater.from(context).inflate(R.layout.listviewitem,null);
            holder=new viewholder(convertView);
            convertView.setTag(holder);
        }else {
            holder= (viewholder) convertView.getTag();
        }
        Starfg1bean bean = mdatas.get(position);
        holder.lfg1list.setText(bean.getTitle());
        holder.rfg1list.setText(bean.getContent());
        holder.rfg1list.setBackgroundResource(bean.getColor());
        return convertView;
    }

    class viewholder{
        TextView lfg1list;
        TextView rfg1list;
        public viewholder(View view){
            lfg1list=view.findViewById(R.id.lfg1list);
            rfg1list=view.findViewById(R.id.rfg1list);
        }
    }
}
